$(() => {
  $('.input_sub').on('click', e => {
    e.preventDefault()
    const username = $('.input_txt').val().trim()
    const password = $('.input_pass').val().trim()
    console.log(username, password)
    let layerId = 0
    $.ajax({
      type: 'post',
      url: "http://localhost:8080/api/v1/admin/user/login",
      data: {
        username,
        password
      },
      beforeSend: () => {
        layerId = layer.load()
      },
      complete: () => {
        layer.close(layerId)
      },
      success: (backData) => {
        console.log(backData)

        if (backData.token) {
          
          localStorage.setItem('token', backData.token)
          window.location.href='./index.html'
        }
      }
    })
  })
})